import axios from 'axios'
import {HOST} from './config'

export function getSingerLists() {
  const url = `${HOST}/top/artists?limit=100`
  return axios.get(url,{withCredentials: true})
}

export function songDetail (id) {
  const url = `${HOST}/song/detail?ids=${id}`
  return axios.get(url,{withCredentials: true})
}

export function getUrl (id) {
  const url = `${HOST}/song/url?id=${id}`
  return axios.get(url,{withCredentials: true})
}

export function singerDetail (name,type,offset) {
  offset = offset ? offset * 30 : 0
  type = type ? type : 0
  let url
  //如果type == 100 意味着搜索结果将出现歌手歌曲混合类型
  if(type){
    url = `${HOST}/search?keywords=${name}&type=${type}`
  }else{
    url = `${HOST}/search?keywords=${name}&offset=${offset}`
  }
  return axios.get(url,{withCredentials: true})
}

export function checkMusic (id) {
  const url = `${HOST}/check/music?id=${id}`
  return axios.get(url,{withCredentials: true})
}

export function getLyrics (id) {
  const url = `${HOST}/lyric?id=${id}`
  return axios.get(url,{withCredentials: true})
}
